//
//  YSOrderBusinessFooterViewFrame.m
//  Yueshi
//
//  Created by Northwan on 15/8/4.
//  Copyright (c) 2015年 悦食中国. All rights reserved.
//

#import "YSOrderBusinessFooterViewFrame.h"

@implementation YSOrderBusinessFooterViewFrame

-(void)setOrder:(YSOrder *)order{
    _order = order;
     //运费
    NSString *freightString = nil;
    CGFloat  priceX = 0;
    
    CGSize priceSize =  [order.orderPrice sizeWithFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
    
     if(order.orderType == OrdinaryOrderType){
         freightString = [NSString stringWithFormat:@"(含运费¥%ld)",order.freight];
         CGSize freightSize =  [freightString sizeWithFont:SYS_FONT(13)];
         self.freightFrame = CGRectMake(SCREENW-YSPublicXInset-freightSize.width, 0, freightSize.width, freightSize.height);
         priceX =  CGRectGetMinX(self.freightFrame)-priceSize.width-12;
     }else{
         freightString = @"";
         CGSize freightSize =  [freightString sizeWithFont:SYS_FONT(13)];
         self.freightFrame = CGRectMake(SCREENW-YSPublicXInset-freightSize.width, 0, freightSize.width, freightSize.height);
         priceX =  CGRectGetMinX(self.freightFrame)-priceSize.width;
     }
    
    //价格
    self.priceFrame =  CGRectMake(priceX, CGRectGetMinY(self.freightFrame), priceSize.width, priceSize.height);
    
    //数量
    NSString *numString = [NSString stringWithFormat:@"共%ld件商品   合计:¥",order.prodCount];
    CGSize numSize =  [numString sizeWithFont:SYS_FONT(15)];
    self.numFrame =   CGRectMake(CGRectGetMinX(self.priceFrame)-numSize.width, CGRectGetMinY(self.priceFrame)-2, numSize.width, numSize.height);

    
    //分割条
    self.spliteFrame = CGRectMake(0, CGRectGetMaxY(self.numFrame)+10, SCREENW, 10);
    
    
    //处理特殊状态显示btn
    if(order.orderStatus == OrderExperienceVolumeChildNotPayType
       ||order.orderStatus == OrderOrdinaryChildNotPayType
       ||order.orderStatus == OrderOrdinaryChildNotReceiveType
       ||order.orderStatus == OrderOrdinaryChildNotReviewType)
    {
        //右边btn
        self.rightBtnFrame = CGRectMake(SCREENW-75-25, CGRectGetMaxY(self.numFrame)+13, 75, 35);
        
        //左边btn
        self.leftBtnFrame = CGRectMake(CGRectGetMinX(self.rightBtnFrame)-75-34, CGRectGetMinY(self.rightBtnFrame), 75, 35);
        
        //分割条
        self.spliteFrame = CGRectMake(0, CGRectGetMaxY(self.leftBtnFrame)+10, SCREENW, 10);
    }
    
    self.footerViewHeight = CGRectGetMaxY(self.spliteFrame);

    self.frame = CGRectMake(0, 0, SCREENW, self.footerViewHeight);
}

@end
